import java.util.Stack;

public class Demo1 {
}
class StockSpanner {
    Stack<int[]> st;
    int i = -1;
    public StockSpanner() {
        this.st = new Stack<>();
        st.push(new int[]{-1,Integer.MAX_VALUE});
    }

    public int next(int price) {
        while(st.peek()[1] <= price){
            st.pop();
        }
        int ans = ++i - st.peek()[0];
        st.push(new int[]{i,price});
        return ans;
    }
}
